<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$strSQL = "select * from `bet_Lotto` where ID = ".(int)$_data["ID"];
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Lotto Data Error!!";
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}else{
	$objLotto = PMA_mysql_fetch_object($RS);
}

//取得此樂透分盤賠率資料
$arrOdds = GetArrayLottoGambleTypeData($objLotto -> ID);
if($arrOdds === false)ErrMsgOutputHTML("Error", "", 1);
//print_r($arrOdds);

$strSQL =  "select ID as BID, Type_Value_".$_intLang." as Type_Value from `bet_BetType` where isGambleType = 1 and LType = ".$objLotto -> LType." order by ID";
if($subRS = @PMA_mysql_query($strSQL, $$_Conn)){
	if(PMA_mysql_num_rows($subRS) > 0){
		while($subRows = PMA_mysql_fetch_object($subRS)){
			$arrBT[$subRows -> BID] = $subRows -> Type_Value;
		}
	}
}

$fp = @file($strTemplatePath."GLine.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{intID}", $objLotto -> ID, $fp);
$strLo = "Lotto_".$_intLang;
$fp = str_replace("{ShowLotto}", $objLotto -> $strLo, $fp);

while(list($k, $v) = each($_strLotto)){
	$fp = str_replace("{".$k."}", $v, $fp);
}
preg_match("/<!-- @ Content Start @ \/\/-->(.+)<!-- @ Content End @ \/\/-->/s", $fp, $arrMatch);
$strConTmp = $arrMatch[1];
preg_match("/<!-- @ GLine1 Start @ \/\/-->(.+)<!-- @ GLine1 End @ \/\/-->/s", $strConTmp, $arrMatch);
$strGLineTmp = $arrMatch[1];

$intRows = 0;
$strSubCon == "";
foreach($_arrBTOrder[$objLotto -> LType] as $intBT){
	if($arrBT[$intBT] == "")continue;
	$arrApointNumTip = $_arrGLineApointNumTip[$objLotto -> ID][$intBT];
	if(!is_array($arrApointNumTip))$arrApointNumTip = array("");

	foreach($arrApointNumTip as $intApointNum => $strApointTip){
		$strSdGLine = MakeGambleTypeSelect("OddsValue", $objLotto -> LType, $intBT, $intApointNum, $arrOdds[$intBT][$intApointNum][1].",".$arrOdds[$intBT][$intApointNum][2].",".$arrOdds[$intBT][$intApointNum][3]);
		$strTmp = $strGLineTmp;
		$strTmp = str_replace("{ShowBTName}", $arrBT[$intBT].$strApointTip, $strTmp);
		$strTmp = str_replace("{SelectGLine}", $strSdGLine, $strTmp);

		$strSubCon .= $strTmp."\n";
		$intRows++;

		if($intRows % 22 == 0){
			$strCon .= preg_replace("/<!-- @ GLine1 Start @ \/\/-->.+<!-- @ GLine1 End @ \/\/-->/s", $strSubCon, $strConTmp);
			$strSubCon = "";
		}
	} //foreach($arrApointNumTip as $intApointNum => $intApointTip)
} //foreach($_arrBTOrder[$objLotto -> LType] as $intBT){
if($strSubCon != "")$strCon .= preg_replace("/<!-- @ GLine1 Start @ \/\/-->.+<!-- @ GLine1 End @ \/\/-->/s", $strSubCon, $strConTmp);
$fp = preg_replace("/<!-- @ Content Start @ \/\/-->.+<!-- @ Content End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>